package cn.hpclub.server.model;

import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;

/**
 * 实体类 - 宽带业务
 * 
 */
@TableBind(tableName = "cmcc_broadbrand")
public class CmccBroadbrand extends Model<CmccBroadbrand> implements Serializable{
    private static final Logger        logger           = LoggerFactory.getLogger(CmccBroadbrand.class);
    private static final long          serialVersionUID = 5108597504836776211L;
    public static final CmccBroadbrand dao              = new CmccBroadbrand();

    public List<Record> getAreaByCity(String city){
        String sql = "select `区县名称` as area from cmcc_broadbrand where `所在城市` =" + "?" + " group by `区县名称`;";
        logger.debug("getAreaByCity sql = " + sql);
        return Db.find(sql, city);
    }

    public List<Record> getAddress(String city, String area, String address){
        String sql = "select `小区名称(主键)` as address,NE_ID as manager_id,`渠道ID` as channel_code,`宽带商家类型` as broad_type "
                + "from cmcc_broadbrand where `所在城市` ='" + city + "' and `区县名称`='" + area + "' and `小区名称(主键)` like '%"
                + address + "%' " + "order by `渠道ID` desc;";

        return Db.find(sql);
    }
}
